
/*loop*/
#[test]
pub fn loop_demo(){
    let mut counter = 1;
    let num = loop {
        counter += 1;
        println!("{}", counter);
        if counter == 10 {
            break counter * 2;
        }
    };
    println!("{}", num);
}

/*while*/
pub fn while_demo(){
    let mut num = 3;
    while num != 0 {
        println!("{}", num);
        num -= 1;
    }
}

/*for*/
pub fn for_demo(){
    let a = [10, 20, 30, 40];
    for n in a.iter() {
        println!("{}", n);
    }
}

/*Range*/
#[test]
pub fn range_demo(){
    for num in 1..4 {
        println!("{}", num);// 1, 2, 3 
    }
    for num in 1..=4 {
        println!("{}", num);// 1, 2, 3, 4
    }
}